<?php
class TagModel{
    protected $text;
    protected $id;
    protected $messages;
    protected $mapper;

    public function save(){
        $this->getMapper()->save($this);
        return $this;
    }

    public function edit(){
        $this->getMapper()->edit($this);
        return $this;
    }

    public function delete(){
        $this->getMapper()->delete($this);
        return $this;
    }

    public function find($tagId){
        $this->getMapper()->find($tagId, $this);
        return $this;
    }

    public function fetchAllTags(){
        return $this->getMapper()->fetchAllTags();

    }

    public function fetchAllTagsById($msg_id){
        return $this->getMapper()->fetchAllTagsById($msg_id);

    }

    public function getCounter(){
        return $this->getMapper()->getCounter();
    }


//=====================================================================
    public function setText($_text){
        $this->text = $_text;
        return $this;
    }
    public function getText(){
        return $this->text;
    }

    public function getMessages(){
        return $this->messages;
    }

    public function setId($_id){
        $this->id = $_id;
        return $this;
    }
    public function getId(){
        return $this->id;
    }

//    public function setUserid($_user_id){
//        $this->user_id = $_user_id;
//        return $this;
//    }
//    public function getUserid(){
//        return $this->user_id;
//    }

    public function setMapper($_mapper){
        $this->mapper = $_mapper;
        return $this;
    }
    public function getMapper(){
        if(!isset($this->mapper)){
            return $this->setMapper(new TagMapper());
        } else {
            return $this->mapper;
        }
    }

}
?>
